These operators work at a bit level and are used to perform bit-level

operations. Solidity supports the following arithmetic operators, as

shown in Table 2.4, as follows:

OPERATOR

DENOTATION

DESCRIPTION

Bitwise AND

&

Performs boolean AND operation on each bit of

integer argument

BitWise OR

|

Performs boolean OR operation on each bit of

integer argument

Bitwise XOR

^

Performs boolean exclusive OR operation on

each bit of integer argument

Bitwise Not

~

Performs boolean NOT operation on each bit of

integer argument

Left Shift

<<

Moves all bits of the first operand to the left by

the number of places specified by the second

operand

Right Shift

>>

Moves all bits of the first operand to the right by

the number of places specified by the second

operand

Table 2.4: Bitwise Operators

Refer to the following code:

// SPDX-License-Identifier: Some Identifier

pragma solidity ^0.8.10;

contract BitwiseContract {

uint a = 10;

uint b = 2;

function bitwiseAnd() public view returns(uint) {

return a & b;

}

function bitwiseOr() public view returns(uint) {

return a | b;

}